package Hw_06;

/**
 * 设计一个人员抽象类(Person)，其中包含一个抽象方法pay，代表人员的工资支出。再从Person类派生出教师类(Teacher)和大学生类(CollegeStudent)。其中
 * 教师的工资支出=基本工资+授课时数*45
 * 大学生的工资支出=奖学金
 */
public class Person {
    public int pay(){
        return 0;
    }
}


class Teacher extends Person{
    private int teachingHours;
    private int wage;

    public Teacher() {
    }

    public Teacher(int wage,int teachingHours ) {
        this.teachingHours = teachingHours;
        this.wage = wage;
    }

    public int getWage() {
        return wage;
    }

    public void setWage(int wage) {
        this.wage = wage;
    }

    public int getTeachingHours() {
        return teachingHours;
    }

    public void setTeachingHours(int teachingHours) {
        this.teachingHours = teachingHours;
    }

    @Override
    public int pay() {
        return getWage()+getTeachingHours()*45;
    }
}


class CollegeStudent extends Person{
    private int scholarship;

    public CollegeStudent() {
    }

    public CollegeStudent(int scholarship) {
        this.scholarship = scholarship;
    }

    public int getScholarship() {
        return scholarship;
    }

    public void setScholarship(int scholarship) {
        this.scholarship = scholarship;
    }

    @Override
    public int pay() {
        return getScholarship();
    }
}


class Test{
    public static void main(String[] args) {
        Person p =new Person();
        p =new Teacher(4000,5);
        System.out.println("教师的工资支出："+p.pay());
        p =new CollegeStudent(1900);
        System.out.println("大学生的工资支出："+p.pay());
    }
}